function observer(value) {
  if (typeof value !== 'object') {
    return;
  }
  var ob = new observer(value)
}

function Observer(data) {
  this.data = data
  this.walk()
}

Observer.prototype = {
  walk:function(){
    var $this = this
    var keys = Object.keys(this.data)
    keys.forEach(key => {
      $this.defineReactive(key, $this.data[key])
    })
  },
  defineReactive: function(key, value) {
    // 收集依赖
    var dep = new dep()
    Object.difineProperty(this.data, key, {
      enumerable: true,
      configurable: true,
      get: function() {
        // 对于每个data的属性值进行依赖收集
        dep.depend()
        return value
      },
      set: function(newValue) {
        if (newValue === value) {
          return
        }
        dep.notify()
      }
    })
  }
}